name: Демонстрация GitVerse CI/CD и cloud.ru Container Registry
on:
  push:
env:
  CR_URI: ildarkahat.cr.cloud.ru
  REPO_NAME: 2024-container-app
jobs:
  build-test:
    name: Demo build and push to Container Registry
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest
    steps:
      - name: Display event name
        run: echo ${{ gitverse.event_name }}

      - name: Display Workflow
        run: echo ${{ gitverse.workflow }}

      - name: Display repository name
        run: echo ${{ gitverse.Repository}}

      - name: Display repository owner
        run: echo ${{ gitverse.repository_owner }}

      - name: Display actor
        run: echo ${{ gitverse.actor }}

      - name: Checkout to the branch
        uses: actions/checkout@v3
        
      - name: Set up Docker buildx
        uses: docker/setup-buildx-action@v2
      
      - name: Log in to Container Registry
        uses: docker/login-action@v2
        with:
          registry: ${{ env.CR_URI }}
          username: ${{ secrets.CR_KEYID }}
          password: ${{ secrets.CR_KEYSECRET }}

      - name: Build and push docker image to Container Registry
        id: build_push
        uses: docker/build-push-action@v3
        with:
          push: true
          platforms: linux/amd64
          provenance: false
          tags: ${{ env.CR_URI }}/${{env.REPO_NAME}}:build${{ github.sha }}
          file: ./build-docker/Dockerfile
          context: .